import time


class Animator(object):
    def __init__(self, marker="█"):
        self._mark = marker

    def draw(self):
        raise NotImplemented("use the subclass draw method instead.")


class TimeSleepAnimator(Animator):
    def __init__(self, marker="█", time_interval=30):
        super().__init__(marker)
        self.time_interval = time_interval

    def _draw(self, percent=0, width=30):
        left = width * percent // 100
        right = width - left
        print('\r休眠: [', self._mark * left, ' ' * right, ']', f' {percent:.0f}%', sep='', end='', flush=True)

    def draw(self):
        for i in range(101):
            self._draw(percent=i)
            time.sleep(self.time_interval / 101)
        print("\n")


if __name__ == "__main__":
    time_animator = TimeSleepAnimator(time_interval=10)
    time_animator.draw()

